package com.yjkf.zh.test.thread;

/**
 * 自动的属性命名主要依靠static属性完成的，在Thread类中定义如下操作
 * private static int threadInitNumber;
 * private static synchronized int nextThreadNum(){
 *     return threadInitNumber++;
 * }
 */
public class MyThread2 {
    public static void main(String[] args){
        MyThread2Test myThread2Test = new MyThread2Test();
        new Thread(myThread2Test,"线程A").start();
        new Thread(myThread2Test).start();          //未设置线程名字
        new Thread(myThread2Test,"线程B").start();
        myThread2Test.run();
    }
}

class MyThread2Test implements Runnable{

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
    }
}